import React from 'react'
import { createBehavior, createResource } from '@designable/core'
import { DnFC } from '@designable/react'
import { AllSchemas } from '../../schemas'
import { AllLocales } from '../../locales'
import { ColorPicker as CustomColorPicker } from '../../customComponents/ColorPicker'
import { createFieldSchema } from '../Field'

export const ColorPicker: DnFC<React.ComponentProps<typeof CustomColorPicker>> =
  CustomColorPicker

ColorPicker.Behavior = createBehavior({
  name: 'ColorPicker',
  extends: ['Field'],
  selector: (node) => node.props['x-component'] === 'ColorPicker',
  designerProps: {
    propsSchema: createFieldSchema(AllSchemas.ColorPicker),
  },
  designerLocales: AllLocales.ColorPicker,
})

ColorPicker.Resource = createResource({
  icon: 'InputSource',
  elements: [
    {
      componentName: 'Field',
      props: {
        type: 'string',
        title: 'ColorPicker',
        'x-decorator': 'FormItem',
        'x-component': 'ColorPicker',
      },
    },
  ],
})
